package com.test.tiles.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.test.tiles.dao.LoginDao;
import com.test.tiles.model.vo.TestVo;
import com.test.tiles.model.vo.UserVo;
import com.test.tiles.model.vo.bbs.Bbs;
import com.test.tiles.service.LoginService;

@Service
public class LoginServiceImpl implements LoginService{
	
	@Autowired
	private LoginDao loginDao;

	@Override
	public List<TestVo> selectTest(TestVo vo) {
		// TODO Auto-generated method stub
		return loginDao.selectTest(vo);
	}
	
	@Override
	public TestVo selectProduct(TestVo vo) {
		// TODO Auto-generated method stub
		int totCnt = loginDao.selectProduct_Cnt(vo);
		vo.setTotCnt(totCnt);
		vo.setObj(loginDao.selectProduct(vo));
		return vo;
	}
	@Override
	public TestVo selectInfom(TestVo vo) {
		// TODO Auto-generated method stub
		return loginDao.selectInfom(vo);
	}

	@Override
	public int insertProduct(TestVo vo) {
		// TODO Auto-generated method stub
		return loginDao.insertProduct(vo);
	}
	
	
	public UserVo login(UserVo vo){
		return loginDao.login(vo);
	}

	@Override
	public int insertBBS(Bbs vo) {
		// TODO Auto-generated method stub
		int resultCnt = loginDao.insertBBS(vo);
		int insertKey = 0;
		if(resultCnt == 1){
			insertKey = loginDao.lastInsertId();
		}
		return  insertKey;
	}
	
	@Override
	public List<Bbs> selectBBS(Bbs vo) {
		// TODO Auto-generated method stub
		List<Bbs> bbs = loginDao.selectBBS(vo);
		return bbs;
	}
	@Override
	public Bbs selectBbsInform(Bbs vo){
		// TODO Auto-generated method stub
		Bbs resultBbs = null;
		List<Bbs> bbs = loginDao.selectBBS(vo);
		if(bbs != null && bbs.size() > 0){
			resultBbs = bbs.get(0);
		}
		return resultBbs;
	}
	

}
